//-------------------------------------------------------------
#include "fiber.h" 
#include <iostream>
namespace tt01
{
    void fun1() 
    {
        std::cout << "1" << std::endl;
        learnco::Fiber::YieldToHold();
        std::cout << "2" << std::endl;
        learnco::Fiber::YieldToHold();
    }

    void fun2() 
    {
        std::cout << "3" << std::endl;
        learnco::Fiber::YieldToHold();
        std::cout << "4" << std::endl;
        learnco::Fiber::YieldToHold();
    }

    void test_fiber()
    {
        std::cout << "main start" << std::endl;
        learnco::Fiber::ptr fiber1(new learnco::Fiber(fun1));
        learnco::Fiber::ptr fiber2(new learnco::Fiber(fun2));

        fiber1->swapIn();
        fiber2->swapIn();

        fiber2->swapIn();
        fiber1->swapIn();
    }
} //namespace
//-------------------------------------------------------------


int main()
{
    tt01::test_fiber();	
}